package com.redlion.object;

import org.andengine.entity.scene.Scene;
import org.andengine.extension.physics.box2d.util.Vector2Pool;
import org.andengine.opengl.texture.region.ITiledTextureRegion;
import org.andengine.util.adt.pool.GenericPool;
import org.andengine.util.debug.Debug;

import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.redlion.Game;
import com.redlion.weapon.LaserStroke;

public class LaserStrokePool extends GenericPool<LaserStroke> {
	private static final String TAG = "ImpactPool";
	private Scene mScene;

	public LaserStrokePool(Scene scene) {
		mScene = scene;
		batchAllocatePoolItems(10);
	}
	public LaserStrokePool() {
		batchAllocatePoolItems(10);
	}
	/**
	 * Called when a Bullet is required but there isn't one in the pool
	 */
	@Override
	protected LaserStroke onAllocatePoolItem() {
		Debug.d(TAG, "onAllocatePoolItem");
		LaserStroke laserStroke = new LaserStroke(0f, 0f, 0f, 0f, 2f, Game.gameActivity.getVertexBufferObjectManager());
		laserStroke.setColor(0.8f, 0.3f, 0.1f);
		laserStroke.deactivate();
		mScene.attachChild(laserStroke);
		return laserStroke;
	}

	/**
	 * Called when a Bullet is sent to the pool
	 */
	@Override
	protected void onHandleRecycleItem(final LaserStroke laserStroke) {
		Debug.d(TAG, "onHandleRecycleItem");
		laserStroke.deactivate();
	}

	/**
	 * Called just before a Bullet is returned to the caller, this is where you
	 * write your initialize code i.e. set location, rotation, etc.
	 */
	@Override
	protected void onHandleObtainItem(final LaserStroke laserStroke) {
		Debug.d(TAG, "onHandleObtainItem");
		laserStroke.activate();
	}
}
